#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMessageBox>
#include <QTextCursor>
#include <memory>
#include <QMainWindow>
#include <QTimer>
#include "EthercatSlave.h"
#include "ServoDrive.h"
#include "SafetyModule.h"
#include "ServoDrive.h"
#include "EthercatMaster.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void timerServoLowUpdateSlot(void);
    void pBConnectSlot(void);
    void pBSetOpSlot(void);
    void pBSetSafeOpSlot(void);
    void pBServoClearFaultSlot(void);
    void pBServoEnabledSlot(void);
    void pBJogSlot(void);

private:
    Ui::MainWindow *ui;
    ECatDrv::EthercatMaster* ecatMaster;
    std::vector<ECatDrv::netCardInfo> m_netCard;
    std::vector<std::shared_ptr<ECatDrv::EthercatSlave>> m_slave;
    std::vector<std::shared_ptr<ECatDrv::ServoDrive>> m_servo;
    std::vector<std::shared_ptr<ECatDrv::SafetyModule>> m_safety;
    std::vector<ECatDrv::masterState> m_slaveCurrentState;

    bool isServoInited;             // 伺服初始化完成标志

    QTimer *ServoLowUpdateTimer;    // 非实时状态更新线程


    void SetLog(QString type, QString str);
    void SetTextLineColor(QColor color);

};
#endif // MAINWINDOW_H
